﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using FluentNHibernate.Mapping;
using Chinook.Core.DomainModel;

namespace Chinook.Core.FNHMappings
{
    public class InvoiceLineMap : ClassMap<InvoiceLine>
    {
         public InvoiceLineMap()
        {
            
            //Table that has been referred to
            Table("InvoiceLine");
            //Mapping for Primary key column
            Id(x => x.Id, "InvoiceLineId").GeneratedBy.Identity();
            //Map table Columns to POCO Fields
            Map(x => x.Quantity);
            Map(x => x.UnitPrice);
            //One-to-one relationship
            //References<Track>(x => x.Track, "TrackId"); //For testing purpose the default value of "2" is hardcoded in the DB level
            //One-to-one relationship
            References<Invoice>(x => x.Invoice).Column("InvoiceId").Cascade.All();
         }       
    }
}
